package cn.bravolinks.tools.controller;

import cn.bravolinks.tools.constant.Constant;
import cn.bravolinks.tools.domain.Task;
import cn.bravolinks.tools.domain.User;
import cn.bravolinks.tools.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Created by yanqin on 2017/6/4.
 */
@Controller
@RequestMapping("user")
public class UserController extends BaseController{

    @Autowired
    private TaskService taskService;

    @RequestMapping("/")
    public String userPage(){
        User u = (User) session.getAttribute(Constant.LOGIN_USER);
        request.setAttribute("user",u);
        //查询该用户的任务
        List<Task> tasks = taskService.get(u.getId());
        request.setAttribute("tasks",tasks);
        return "user";
    }
}
